//
//  PushViewController.m
//  06-NavigationController
//
//  Created by 王道林 on 16/7/21.
//  Copyright © 2016年 王道林. All rights reserved.
//

#import "PushViewController.h"

@interface PushViewController ()

@end

@implementation PushViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.backgroundColor = [UIColor redColor];
    button.frame = CGRectMake(0, 0, 300, 300);
    [self.view addSubview:button];
    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)buttonAction:(UIButton *)button
{
    // pop 当前ViewController 出栈
    // pop  有好几种方法   pop到不同的VC
    [self.navigationController popViewControllerAnimated:YES];
    
    // pop 到根视图控制器
    [self.navigationController popToRootViewControllerAnimated:YES];
    // 返回栈中指定的视图控制器
 //   [self.navigationController popToViewController:<#(nonnull UIViewController *)#> animated:<#(BOOL)#>]
    
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
